package com.yiqi.liebang.feature.mine.view;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.framework.AM;
import com.suozhang.framework.framework.BaseActivity;
import com.suozhang.framework.framework.Callback;
import com.suozhang.framework.utils.T;
import com.suozhang.framework.utils.logger.Logger;
import com.suozhang.framework.widget.EmptyView;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;
import com.yiqi.liebang.R;
import com.yiqi.liebang.common.rongim.msg.CustomizeMessage;
import com.yiqi.liebang.common.widget.ShareBottomDialog;
import com.yiqi.liebang.common.widget.SimpleCustomPop;
import com.yiqi.liebang.common.widget.dialog.BaseAnimatorSet;
import com.yiqi.liebang.common.widget.dialog.BounceTopEnter;
import com.yiqi.liebang.common.widget.dialog.NormalDialog;
import com.yiqi.liebang.common.widget.dialog.OnBtnClickL;
import com.yiqi.liebang.common.widget.dialog.SlideBottomExit;
import com.yiqi.liebang.common.widget.dialog.SlideTopExit;
import com.yiqi.liebang.entity.bo.PeopleBo;
import com.yiqi.liebang.entity.bo.UserCardBo;
import com.yiqi.liebang.entity.bo.UserCenterBo;
import com.yiqi.liebang.entity.bo.UserDataBo;
import com.yiqi.liebang.feature.home.view.AddSuccessActivity;
import com.yiqi.liebang.feature.home.view.AskActivity;
import com.yiqi.liebang.feature.mine.contract.UserContract;
import com.yiqi.liebang.feature.mine.dependencies.login.DaggerUserComponent;
import com.yiqi.liebang.feature.mine.dependencies.login.UserPresenterModule;
import com.yiqi.liebang.feature.mine.view.adapter.MultipleUserItem;
import com.yiqi.liebang.feature.mine.view.adapter.UserInfoAdpter;
import com.yiqi.liebang.feature.people.view.FriendsListActivity;
import com.yiqi.liebang.framework.DataServer;
import com.yiqi.liebang.framework.api.UserApi;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.OnClick;
import cn.rongcloud.contactcard.Friend;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.rong.imkit.RongIM;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;

import static com.suozhang.framework.utils.AppUtil.fullScreen;

public class UserInfoActivity extends BaseActivity implements UserContract.View, View.OnClickListener, OnRefreshListener, BaseQuickAdapter.OnItemChildClickListener, BaseQuickAdapter.OnItemClickListener {

    @Inject
    UserContract.Presenter mPresenter;
    @BindView(R.id.smartRefesh)
    SmartRefreshLayout mSmartRefesh;
    @BindView(R.id.view_friend)
    LinearLayout mViewFriend;

    @BindView(R.id.iv_info_like)
    ImageView mIvInfoLike;
    @BindView(R.id.tv_info_like)
    TextView mTvInfoLike;
    @BindView(R.id.tv_msg)
    TextView mTvMsg;
    @BindView(R.id.btn_click)
    Button mBtnClick;
    @BindView(R.id.view_no_authorized_access)
    LinearLayout mViewNoAuthorizedAccess;
    private boolean isEdit = false;
    EmptyView mEmptyView;

    @BindView(R.id.rv_userinfo)
    RecyclerView mRvUserinfo;

    UserInfoAdpter mHomeAdapter;
    UserCenterBo mUserCenterBo;
    private boolean isLookMine = true;
    private String mVisitorUid;
    SimpleCustomPop mQuickCustomPopup;
    private int isLike = 0;
    ShareBottomDialog mShareDialog;

    private static String[] mItemsMIne = {"分享猎帮名片"};
    private static String[] mItemsOther = {"分享猎帮名片", "拉黑/屏蔽", "解除好友关系"};
    private static String[] mItemsOtherNot = {"分享猎帮名片", "拉黑/屏蔽", "加为好友"};
    private BaseAnimatorSet mBasIn;
    private BaseAnimatorSet mBasOut;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_user_info;

    }

    UMImage image;//网络图片
    UMWeb umWeb;

    @Override
    protected void initSystemParams() {
//        super.initSystemParams();
        fullScreen(this);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    @Override
    protected void initInjector() {
        DaggerUserComponent.builder().userPresenterModule(new UserPresenterModule(this)).build().inject(this);
    }

    @Override
    protected void initView() {

        isEdit = this.getIntent().getBooleanExtra("isEdit", false);
        isLookMine = this.getIntent().getBooleanExtra("is_view_my", true);
        mVisitorUid = this.getIntent().getStringExtra("visitorUid");


        mRvUserinfo.setLayoutManager(new LinearLayoutManager(this));
        mEmptyView = new EmptyView(mRvUserinfo);
        mSmartRefesh.setEnableLoadMore(false);
        mSmartRefesh.setOnRefreshListener(this);


    }

    private void initHomeList(boolean isEdit, UserCenterBo s) {
        image = new UMImage(this, s.getUserHead());
        umWeb = new UMWeb("http://liebangapp.com/yindao/");
        umWeb.setTitle(s.getUserName());//标题
        umWeb.setThumb(image);  //缩略图
        umWeb.setDescription(s.getPosition());//描述

        List<MultipleUserItem> list = new ArrayList<>();
        list.add(new MultipleUserItem(MultipleUserItem.ITEM_TOP, MultipleUserItem.IMG_SPAN_SIZE));
        if (!isEdit) {
            if (s.getUserStatus() == 0) {
                    list.add(new MultipleUserItem(MultipleUserItem.ITEM_ASK, MultipleUserItem.IMG_SPAN_SIZE));


                if (!TextUtils.isEmpty(s.getUserIntroduce())) {
                    list.add(new MultipleUserItem(MultipleUserItem.ITEM_ZWJS, MultipleUserItem.IMG_SPAN_SIZE));
                }
                if (s.getOccupationAuthentication() != null && s.getOccupationAuthentication().size() > 0) {
                    list.add(new MultipleUserItem(MultipleUserItem.ITEM_GZJL, MultipleUserItem.IMG_SPAN_SIZE));
                }
                if (s.getEducationAuthentication() != null && s.getEducationAuthentication().size() > 0) {
                    list.add(new MultipleUserItem(MultipleUserItem.ITEM_JYJL, MultipleUserItem.IMG_SPAN_SIZE));
                }
                if (!TextUtils.isEmpty(s.getUserHometown()) || !TextUtils.isEmpty(s.getUserBirth())) {
                    list.add(new MultipleUserItem(MultipleUserItem.ITEM_GDZL, MultipleUserItem.IMG_SPAN_SIZE));
                }

                if (s.getUserClassify() != null && s.getUserClassify().size() > 0) {
                    list.add(new MultipleUserItem(MultipleUserItem.ITEM_ZYBQ, MultipleUserItem.IMG_SPAN_SIZE));
                }
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_PINGLUN, MultipleUserItem.IMG_SPAN_SIZE));

                if (s.getUserFriend() != null && s.getUserFriend().size() > 0) {
                    list.add(new MultipleUserItem(MultipleUserItem.ITEM_HYTJ, MultipleUserItem.IMG_SPAN_SIZE));
                }
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_FFXZ, MultipleUserItem.IMG_SPAN_SIZE));
            } else {
                mViewFriend.setVisibility(View.GONE);
            }
        } else {
            if (s.getUserStatus() == 0) {
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_ASK, MultipleUserItem.IMG_SPAN_SIZE));
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_ZWJS, MultipleUserItem.IMG_SPAN_SIZE));
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_GZJL, MultipleUserItem.IMG_SPAN_SIZE));
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_JYJL, MultipleUserItem.IMG_SPAN_SIZE));
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_GDZL, MultipleUserItem.IMG_SPAN_SIZE));
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_ZYBQ, MultipleUserItem.IMG_SPAN_SIZE));
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_PINGLUN, MultipleUserItem.IMG_SPAN_SIZE));
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_HYTJ, MultipleUserItem.IMG_SPAN_SIZE));
                list.add(new MultipleUserItem(MultipleUserItem.ITEM_FFXZ, MultipleUserItem.IMG_SPAN_SIZE));
            } else {
                mViewFriend.setVisibility(View.GONE);
            }
        }


        mHomeAdapter = new UserInfoAdpter(list, isEdit, isLookMine, this, s);
        mHomeAdapter.setAddUserClickListener(new Callback.CommonCallback() {
            @Override
            public void onSubscribe(Disposable d) {
                showLoading(d);
            }

            @Override
            public void onSuccess(Object result) {
                dismissLoading();
            }

            @Override
            public void onError(Throwable ex) {
                dismissLoading();
            }

            @Override
            public void onComplete() {
                dismissLoading();
            }
        });
        mRvUserinfo.setAdapter(mHomeAdapter);
        mHomeAdapter.setWxClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mQuickCustomPopup
                        .anchorView(v)
                        .offset(-10, 35)
                        .gravity(Gravity.TOP)
                        .showAnim(new BounceTopEnter())
                        .dismissAnim(new SlideTopExit())
                        .dimEnabled(false);
                mQuickCustomPopup.setWxCircleClickListener(UserInfoActivity.this);
                if (!mQuickCustomPopup.isShowing()) {
                    mQuickCustomPopup.show();
                }
            }
        });

        isLike = s.getIsLike();
        if (isLike == 0) {
            mTvInfoLike.setText("喜欢");
            mIvInfoLike.setImageResource(R.drawable.tab_icon_like);
        } else {
            mTvInfoLike.setText("取消喜欢");
            mIvInfoLike.setImageResource(R.drawable.icon_like);
        }

    }

    private UMShareListener shareListener = new UMShareListener() {
        @Override
        public void onStart(SHARE_MEDIA platform) {
            showLoading();
        }

        @Override
        public void onResult(SHARE_MEDIA platform) {
            dismissLoading();
            T.showShort("分享成功！");
            if (mShareDialog != null) mShareDialog.dismiss();
        }

        @Override
        public void onError(SHARE_MEDIA platform, Throwable t) {
            dismissLoading();
            T.showShort("分享失败！");
            if (mShareDialog != null) mShareDialog.dismiss();
        }

        @Override
        public void onCancel(SHARE_MEDIA platform) {
            dismissLoading();
            T.showShort("分享取消！");

        }
    };

    @Override
    protected void onStart() {
        super.onStart();
        if (isLookMine && AM.user().isLogin()) {
            mPresenter.getUserData(AM.user().getLoginResultCache().getUserUid(), 0, null);
        } else {
            mPresenter.getUserData(AM.user().getLoginResultCache().getUserUid(), 1, mVisitorUid);
        }
    }

    @Override
    protected void initData() {
        mBasIn = new BounceTopEnter();
        mBasOut = new SlideBottomExit();

    }


    @Override
    protected void initEvent() {

    }

    @Override
    public void showUserCenterSuccess(UserCenterBo s) {
        mRvUserinfo.setVisibility(View.VISIBLE);
        mViewNoAuthorizedAccess.setVisibility(View.GONE);


        mUserCenterBo = s;
        if (AM.user().getLoginResultCache().getUserUid().equals(mUserCenterBo.getUserUid())) {
            isLookMine = true;
        }
        if (isLookMine) {
            mViewFriend.setVisibility(View.GONE);
            mPresenter.getUserData(AM.user().getLoginResultCache().getUserUid(), 0, null);
            mQuickCustomPopup = new SimpleCustomPop(UserInfoActivity.this, Arrays.asList(mItemsMIne));
        } else {
            mPresenter.getUserData(AM.user().getLoginResultCache().getUserUid(), 1, mVisitorUid);
            mViewFriend.setVisibility(View.VISIBLE);

            if (s.getIsFriend() == 0) {
                mQuickCustomPopup = new SimpleCustomPop(UserInfoActivity.this, Arrays.asList(mItemsOtherNot));
            } else {
                mQuickCustomPopup = new SimpleCustomPop(UserInfoActivity.this, Arrays.asList(mItemsOther));
            }
        }

        mSmartRefesh.finishRefresh();

        initHomeList(isEdit, mUserCenterBo);

    }

    @Override
    public void showUserCenterError(String error) {
        mRvUserinfo.setVisibility(View.GONE);
        mViewNoAuthorizedAccess.setVisibility(View.VISIBLE);
        mTvMsg.setText(error);

    }

    @Override
    public void showUserCardSuccess(UserCardBo s) {

    }

    @Override
    public void showMineSuccess(UserDataBo s) {

    }

    @Override
    public void showDeleteFriendSuccess() {
        showMsg("解除好友关系成功！");
        finish();
    }

    @Override
    public void showAddBlackSuccess() {
        showMsg("加入黑名单成功！");
        finish();
    }

    @Override
    public void showLikeSuccess() {
        if (isLike == 0) {
            showMsg("喜欢成功！");
            isLike = 1;
            mTvInfoLike.setText("取消喜欢");
            mIvInfoLike.setImageResource(R.drawable.icon_like);
        } else {
            showMsg("取消喜欢成功！");
            isLike = 0;
            mTvInfoLike.setText("喜欢");
            mIvInfoLike.setImageResource(R.drawable.tab_icon_like);
        }

    }

    @Override
    public void showPrivateSuccess(Boolean id) {
        if (id != null && id) {
            RongIM.getInstance().startPrivateChat(this, mUserCenterBo.getUserUid(), mUserCenterBo.getUserName());
        }else {
             NormalDialog dialog = new NormalDialog(this);
            dialog.content("对方设置私信权限！")//
                    .btnNum(1)
                    .btnText("取消")//
                    .show();

            dialog.setOnBtnClickL(new OnBtnClickL() {
                @Override
                public void onBtnClick() {
                    dialog.dismiss();
                }
            });
        }

    }

    @Override
    public void showUserEditSuccess() {

    }

    @Override
    public void showError(String error) {
        mSmartRefesh.finishRefresh();
        showMsg(error);
    }

    @Override
    public void onClick(View v) {

    }


    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        if (isLookMine) {
            mViewFriend.setVisibility(View.GONE);
            mPresenter.getUserData(AM.user().getLoginResultCache().getUserUid(), 0, null);
        } else {
            mPresenter.getUserData(AM.user().getLoginResultCache().getUserUid(), 1, mVisitorUid);
            mViewFriend.setVisibility(View.VISIBLE);
        }
    }


    @OnClick({R.id.btn_info_like, R.id.btn_info_message, R.id.btn_info_question, R.id.btn_info_order})
    public void onViewClicked(View view) {
        if (mUserCenterBo == null) {
            return;
        }
        switch (view.getId()) {
            case R.id.btn_info_like:
                if (isLike == 0) {
                    mPresenter.likeUser(mUserCenterBo.getUserUid(), 1);
                } else {
                    mPresenter.likeUser(mUserCenterBo.getUserUid(), 0);
                }

                break;
            case R.id.btn_info_message:

                mPresenter.privateUser(mUserCenterBo.getUserUid());
                break;
            case R.id.btn_info_question:

                if (mUserCenterBo.getIsBasic() == 1 || mUserCenterBo.getIsOccupation() == 1 ||
                        mUserCenterBo.getIsEducation() == 1 || mUserCenterBo.getMechanism() == 1) {
                    Intent intent = new Intent(this, AskActivity.class);
                    intent.putExtra("user_id", mUserCenterBo.getUserUid());
                    startActivity(intent);
                } else {
                    final NormalDialog dialog = new NormalDialog(this);
                    dialog.content("TA还不是行家，不能向TA提问~")//
                            .btnNum(1)
                            .btnText("取消")//
                            .showAnim(mBasIn)//
                            .dismissAnim(mBasOut)//
                            .show();

                    dialog.setOnBtnClickL(new OnBtnClickL() {
                        @Override
                        public void onBtnClick() {
                            dialog.dismiss();
                        }
                    });
                }
                break;

            case R.id.btn_info_order:

                if (mUserCenterBo.getIsBasic() == 1 || mUserCenterBo.getIsOccupation() == 1 || mUserCenterBo.getIsEducation() == 1 || mUserCenterBo.getMechanism() == 1) {
                    if (mUserCenterBo.getTopic()!=null&&mUserCenterBo.getTopic().size()>0){
                        TopicListDialog topicListDialog = new TopicListDialog(this, mUserCenterBo.getTopic(), isLookMine,mUserCenterBo.getUserUid());
                        topicListDialog.show();
                    }else {
                        showDialog("该用户没有话题商品");
                    }
                }else {
                    showDialog("TA目前还不是行家");
                }

                break;
        }
    }

    public  void showDialog(String msg){
        final NormalDialog dialog = new NormalDialog(this);
        dialog.content(msg)//
                .btnNum(1)
                .btnText("取消")//
                .show();

        dialog.setOnBtnClickL(new OnBtnClickL() {
            @Override
            public void onBtnClick() {
                dialog.dismiss();
            }
        });
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
        if (requestCode == 23) {

            try {

                Friend friend = data.getParcelableExtra("three");
                Friend friendSend = new Friend();
                friendSend.setUserUid(mUserCenterBo.getUserUid());
                friendSend.setUserName(mUserCenterBo.getUserName());
                friendSend.setUserHead(mUserCenterBo.getUserHead());
                friendSend.setEffectSocre(mUserCenterBo.getEffectScore());
                friendSend.setUserWorkAddress(mUserCenterBo.getUserWorkAddress());
                friendSend.setUserEmail(mUserCenterBo.getUserEmail());
                friendSend.setUserClassify(mUserCenterBo.getUserClassify() != null ? DataServer.getClassfiyStr(mUserCenterBo.getUserClassify()) : "");
                friendSend.setComLogo(mUserCenterBo.getComLogo());
                friendSend.setIsEducation(mUserCenterBo.getIsEducation());
                friendSend.setIsBasic(mUserCenterBo.getIsBasic());
                friendSend.setIsOccupation(mUserCenterBo.getIsOccupation());
                friendSend.setPosition(mUserCenterBo.getPosition());

                String json = JSONObject.toJSONString(friendSend);

                CustomizeMessage message = CustomizeMessage.obtain(
                        "",
                        "",
                        friend.getUserUid(),
                        "",
                        json,
                        "",
                        mUserCenterBo.getIsEducation(),
                        mUserCenterBo.getUserUid(),
                        mUserCenterBo.getUserName(),
                        mUserCenterBo.getIsBasic(),
                        "",
                        mUserCenterBo.getIsOccupation(),
                        mUserCenterBo.getUserHead(),
                        mUserCenterBo.getPosition(),
                        "",
                        mUserCenterBo.getComLogo(),
                        "",
                        mUserCenterBo.getUserClassify() != null ? DataServer.getClassfiyStr(mUserCenterBo.getUserClassify()) : "",
                        mUserCenterBo.getUserEmail(),
                        mUserCenterBo.getUserWorkAddress(),
                        mUserCenterBo.getEffectScore(),
                        friend.getUserPhone(),
                        friend.getPhonePrivacy(),
                        friend.getPhone()
                );
                RongIM.getInstance().sendMessage(Message.obtain(friend.getUserUid(), Conversation.ConversationType.PRIVATE, message), "sass", "sss",
                        new IRongCallback.ISendMessageCallback() {
                            @Override
                            public void onAttached(Message message) {

                            }

                            @Override
                            public void onSuccess(Message message) {
                                showMsg("已发送！");
                                if (mShareDialog != null) mShareDialog.dismiss();
                                RongIM.getInstance().startConversation(UserInfoActivity.this, Conversation.ConversationType.PRIVATE, friend.getUserUid(), friend.getUserName());
                            }

                            @Override
                            public void onError(Message message, RongIMClient.ErrorCode errorCode) {
                                T.showShort("onError" + errorCode.getMessage());
                            }
                        });
            } catch (Exception e) {
                Logger.e("Exception--->" + e.getMessage());
            }
        }
    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        {
            switch (position) {
                case 0:
                    mQuickCustomPopup.dismiss();
                    BaseAnimatorSet mBasIn = new BounceTopEnter();
                    mShareDialog = new ShareBottomDialog(UserInfoActivity.this, view, false);

                    mShareDialog.setWxCircleClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            new ShareAction(UserInfoActivity.this)
                                    .setPlatform(SHARE_MEDIA.WEIXIN_CIRCLE)//传入平台
                                    .withMedia(umWeb)
                                    .setCallback(shareListener)//回调监听器
                                    .share();
                        }
                    });

                    mShareDialog.setWxClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            new ShareAction(UserInfoActivity.this)
                                    .setPlatform(SHARE_MEDIA.WEIXIN)//传入平台
                                    .withMedia(umWeb)
                                    .setCallback(shareListener)//回调监听器
                                    .share();
                        }
                    });
                    mShareDialog.setLBClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(UserInfoActivity.this, FriendsListActivity.class);
                            intent.putExtra("is_select", true);
                            startActivityForResult(intent, 23);
                        }
                    });
                    mShareDialog.showAnim(mBasIn)
                            .show();//
                    break;
                case 1:

                    mPresenter.addBlack(mUserCenterBo.getUserUid());

                    break;

                case 2:
                    if (mUserCenterBo.getIsFriend() == 0 && !isLookMine) {
                        addFriend(mUserCenterBo.getUserUid());
                    } else {
                        mPresenter.deleteFriend(mUserCenterBo.getUserUid());
                    }

                    break;
            }
        }
    }


    private void addFriend(String userUid) {
        PeopleBo peopleBo = new PeopleBo();
        peopleBo.setApplicationUserUid(userUid);

        AM.api().createApiService(UserApi.class)
                .getAddFriend(peopleBo)
                .compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer())
                .subscribe(new Observer<String>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        showLoading(d);
                    }

                    @Override
                    public void onNext(String s) {
                        dismissLoading();
                        Intent intent = new Intent(UserInfoActivity.this, AddSuccessActivity.class);
                        startActivity(intent);
                    }

                    @Override
                    public void onError(Throwable e) {
                        dismissLoading();
                        T.showShort(e.getMessage());
                    }

                    @Override
                    public void onComplete() {
                        dismissLoading();
                    }
                });
    }


    @OnClick(R.id.btn_click)
    public void onViewClicked() {
        finish();
    }
}
